package com.mryan.esjd.controller;

import com.mryan.esjd.service.ParseJDservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @description：TODO
 * @Author MRyan
 * @Date 2020/6/23 21:46
 * @Version 1.0
 */
@RestController
public class JdParseController {

    @Autowired
    private ParseJDservice parseJDservice;

    @GetMapping("/parse/{keyword}")
    public Boolean parse(@PathVariable("keyword") String keywords) throws IOException {
        return parseJDservice.parseJD(keywords);
    }


    @GetMapping("/search/{keyword}/{page}/{pagesize}")
    public List<Map<String, Object>> search(@PathVariable("keyword") String keyword,
                                            @PathVariable("page") int page,
                                            @PathVariable("pagesize") int pagesize) throws IOException {
        List<Map<String, Object>> maps = parseJDservice.srarchPage(keyword, page, pagesize);
        return maps;
    }

}
